Imports Microsoft.VisualBasic

Namespace MyMVC
    Public MustInherit Class MVCComponent
        Protected dataInternal As TemplateControl

        Public Sub New(ByVal dataInternal As TemplateControl)
            Me.dataInternal = dataInternal
        End Sub

        Public Function GetLocalResourceObject(ByVal resourceKey As String) As String
            Return HttpContext.GetLocalResourceObject(Me.VirtualPath, resourceKey)
        End Function

        Public Function GetLocalResourceObject(ByVal resourceKey As String, ByVal ParamArray args() As Object) As String
            Return String.Format(Me.GetLocalResourceObject(resourceKey), args)
        End Function

        Public ReadOnly Property VirtualPath() As String
            Get
                Dim ext As String = VirtualPathUtility.GetExtension(Me.dataInternal.AppRelativeVirtualPath)

                Return Me.dataInternal.AppRelativeVirtualPath.Replace(VirtualPathUtility.GetExtension(Me.dataInternal.AppRelativeVirtualPath), Me.VirtualPathExtension)
            End Get
        End Property

        Public MustOverride ReadOnly Property VirtualPathExtension() As String

    End Class
End Namespace
